#include<iostream>
using namespace std ;
typedef long long ll ; 
ll rd(){
	ll a = 0 ; 
	scanf("%lld",&a) ; 
	return a ; 
} 
int const AS_LEN = 1e5+10;
ll as[AS_LEN] = {0};

int myfun(){
	ll l  = rd() , r = rd() ; 
	l-- ;
	printf("%lld\n",as[r] - as[l]);

	return 0 ; 
}
int main(){
	ll n = rd() ; 
	
	for(int i = 1 ; i <= n ; i++){
		as[i] = rd();
	} 
	for(int i = 1 ; i <= n ;i++){
		as[i] = as[i] + as[i-1] ; 
	}
	ll m = rd(); 
	while(m--)
		myfun() ; 
	
	return 0 ; 
}